package cn.arifun.service;

import cn.arifun.entity.SysUser;
import cn.arifun.manage.SysUserManage;
import cn.arifun.mapper.SysUserMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;

/**
 * @Author: 漆原
 * @Description: 系统用户业务类
 * @DateTime: 2024/10/1 15:34
 **/
@Service
public class SysUserService extends ServiceImpl<SysUserMapper, SysUser> {
    @Resource
    private SysUserManage userManage;

    public void addUser(SysUser sysUser) {
        //UserDetails userDetails = User.withUsername(sysUser.getName()).password(sysUser.getPassword()).build();
        UserDetails userDetails = User.withDefaultPasswordEncoder().username(sysUser.getName()).password(sysUser.getPassword()).build();
        userManage.createUser(userDetails);
    }
}
